package com.hz.house.common;

import com.hz.house.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.hz.house.dao.FAQMapper;
import com.hz.house.service.BbsCacheService;

import lombok.extern.slf4j.Slf4j;

/**
 * 项目启动立即执行某些函数
 * 
 * @author lfw
 *
 */
@Component
@Slf4j
public class SpringCommand implements CommandLineRunner{

	@Autowired
	private FAQMapper fAQMapper;
	
	@Autowired
	private BbsCacheService bbsCacheService;

	@Autowired
	private ArticleService articleService;
	
	@Override
	public void run(String... args) throws Exception {
		 
		log.info("社区论坛服务启动....");
		log.info("初始化最大问题id...");
		Integer maxId= this.fAQMapper.getMaxFAQId();
		bbsCacheService.setMaxFaqid(maxId==null?0:maxId);

		// 启动买房必读访问量统计线程
		articleService.startCountWorker();
	}

	 

}
